package com.summer.shopping.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.summer.shopping.domain.table.Quan;
import com.summer.shopping.service.QuanService;
import com.summer.shopping.mapper.QuanMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
* @author 86136
* @description 针对表【quan(优惠券表)】的数据库操作Service实现
* @createDate 2025-06-20 13:57:18
*/
@Service
public class QuanServiceImpl extends ServiceImpl<QuanMapper, Quan>
    implements QuanService{

    @Resource
    private QuanMapper quanMapper;

    @Override
    public int addNewQuan(Quan quan) {
        String name = quan.getName();
        Quan one = lambdaQuery().eq(Quan::getName, name).one();
        if (one != null) {
            return 0;
        }
        return quanMapper.insert(quan);
    }

    @Override
    public List<Quan> getCheckInQuan() {
        return lambdaQuery().likeLeft(Quan::getName, "-签到")
                            .list();
    }


}




